//
//  BaseTableViewController.swift
//  SinaBlog
//
//  Created by 有何不可 on 15/12/30.
//  Copyright © 2015年 有何不可. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, LoginViewDelegate {
    
    var islogin: Bool = false
    var vision: LoginView?
    
    override func loadView() {
        
        islogin = OauthViewModel.sharedInstance.isLogin
        
        if islogin {
            
           super.loadView()
            
        }else {
            
           vision = LoginView()
            
            view = vision
            
            vision?.setAnimation()
            
            vision?.delegate = self
            
            setNav()
        } 
    }
    
    // MARK:--代理方法的实现
    
    func didRegisterBtn() {
//        printLog("0")
        
        let nav = UINavigationController(rootViewController: OauthViewController())
        
        self.presentViewController(nav, animated: true, completion: nil)
    }
    
    func didLoginBtn() {
//        printLog("1")
    }

    func setNav() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "didRegisterBtn")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "didLoginBtn")
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
